package com.ruoyi.thread;

import lombok.Data;

import java.util.stream.IntStream;

@Data
public class LockTest1 {
    public static void main(String[] args) {
        IntStream.rangeClosed(1, 100000).parallel().forEach(i -> new LockTest1().increase());
        System.out.println(time);
    }

    private static int time = 0;

    private static Object lock = new Object();
    public void increase() {
        synchronized (lock) {
            time++;
        }
    }
}
